Param(
    [Parameter(Mandatory=$true)] [string]$OutputPath,
    [int]$Width = 480,
    [int]$Height = 270,
    [string]$Message = '启动中...'
)

Add-Type -AssemblyName System.Drawing
$bmp = New-Object Drawing.Bitmap $Width, $Height
$g = [Drawing.Graphics]::FromImage($bmp)
$g.SmoothingMode = [Drawing.Drawing2D.SmoothingMode]::AntiAlias
$g.Clear([Drawing.Color]::White)

$font = New-Object System.Drawing.Font('Segoe UI', 20, [System.Drawing.FontStyle]::Bold, [System.Drawing.GraphicsUnit]::Pixel)
$brush = [Drawing.Brushes]::Black

# 测量文本尺寸以便居中
$sizeF = $g.MeasureString($Message, $font)
$x = [int](($Width - $sizeF.Width) / 2)
$y = [int](($Height - $sizeF.Height) / 2)
$g.DrawString($Message, $font, $brush, $x, $y)

$dir = Split-Path -Parent $OutputPath
if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir | Out-Null }
$bmp.Save($OutputPath, [Drawing.Imaging.ImageFormat]::Png)

$g.Dispose()
$bmp.Dispose()
